package com.sw.study.ssm.service.impl;

import com.sw.study.ssm.dao.ResumeDao;
import com.sw.study.ssm.pojo.Resume;
import com.sw.study.ssm.service.IResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * Created by sw on 2020/4/18.
 */
@Service
public class ResumeServiceImpl implements IResumeService {
    @Autowired
    private ResumeDao resumeDao;

    @Override
    public List<Resume> queryList() {
        return resumeDao.findAll();
    }

    /**
     * 不一定实现这个方法
     *
     * @param id
     * @return
     */
    @Override
    public Resume queryById(Long id) {
        Optional<Resume> resume = resumeDao.findById(id);
        if (resume.isPresent()){
            return resume.get();
        }
        return null;
    }

    /**
     * 修改
     *
     * @param resume
     * @return
     */
    @Override
    public Resume updateResume(Resume resume) {
        return resumeDao.save(resume);
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public void deleteResumeById(Long id) {
         resumeDao.deleteById(id);
    }

    /**
     * 插入
     *
     * @param resume
     * @return
     */
    @Override
    public Resume inserResume(Resume resume) {
        return resumeDao.save(resume);
    }
}